package com.weilx959.spt.core.constants;

import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;

public enum ShortcutKey {

    SAVE_WORKSPACE {
        @Override
        public KeyCodeCombination key() {
            return isMac() ? new KeyCodeCombination(KeyCode.S, KeyCombination.META_DOWN)
                    : new KeyCodeCombination(KeyCode.S, KeyCombination.CONTROL_DOWN);
        }
    },
    NEW_WORKSPACE {
        @Override
        public KeyCodeCombination key() {
            return isMac() ? new KeyCodeCombination(KeyCode.N, KeyCombination.META_DOWN)
                    : new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
        }
    },
    OPEN_WORKSPACE {
        @Override
        public KeyCodeCombination key() {
            return isMac() ? new KeyCodeCombination(KeyCode.O, KeyCombination.META_DOWN)
                    : new KeyCodeCombination(KeyCode.O, KeyCombination.CONTROL_DOWN);
        }
    };

    public abstract KeyCodeCombination key();

    boolean isMac() {
        return System.getProperty("os.name").toLowerCase().contains("mac");
    }
}
